/**
 * 简单打包脚本 - 不使用vsce
 * 用于诊断VSCode插件激活问题
 * 
 * @author lihengtt <lihengsir@gmail.com>
 * @github https://github.com/lihengtt
 */

const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');

// 创建临时目录
const tempDir = path.join(__dirname, 'test-extension');
if (fs.existsSync(tempDir)) {
  fs.rmSync(tempDir, { recursive: true, force: true });
}
fs.mkdirSync(tempDir, { recursive: true });
fs.mkdirSync(path.join(tempDir, 'out'), { recursive: true });

// 复制必要文件
fs.copyFileSync(
  path.join(__dirname, 'package-minimal.json'),
  path.join(tempDir, 'package.json')
);

fs.copyFileSync(
  path.join(__dirname, 'out', 'extension-minimal.js'),
  path.join(tempDir, 'out', 'extension-minimal.js')
);

// 创建简单的图标文件
const iconDir = path.join(tempDir, 'resources');
fs.mkdirSync(iconDir, { recursive: true });

const svgContent = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  <path d="M12 2L2 7L12 12L22 7L12 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  <path d="M2 17L12 22L22 17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  <path d="M2 12L12 17L22 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`;

fs.writeFileSync(path.join(iconDir, 'cloud-upload.svg'), svgContent);

console.log('测试插件准备完成，请使用以下命令安装:');
console.log(`code --install-extension ${tempDir}`);
console.log('\n安装后重启VSCode并尝试执行命令: Rsync Deployment: 配置Rsync部署');